<!-- Add fancyBox main JS and CSS files -->
<script type="text/javascript" src="{$addon_path}Public/jquery.fancybox.js?v=2.1.5"></script>
<link rel="stylesheet" type="text/css" href="{$addon_path}Public/jquery.fancybox.css?v=2.1.5" media="screen" />
<script type="text/javascript">
$(function(){
	$("div[id^='upload_picture_']").parent(".controls").each(function(index, element) {
        $(this).css({"position":"relative"});
		$name = $(this).find("input[type='hidden']").attr('name');
		$SelectButtonHtml = "<input type='button' class='btn selectImg' data-name='" + $name + "' value='选择图片' />";
		$(this).append($SelectButtonHtml);
    });
	//$("div[id^='upload_picture_']").parent(".controls").css({"position":"relative"}).append("<input type='button' class='btn selectImg' value='选择图片' />");
})
$(document).delegate(".selectImg", "click", function() {
	$name = $(this).data("name");
	$id   = $(this).data("id");
	$.fancybox.open({
		href : "{:addons_url('ImageManager://ImageManager/ImageManager')}&name="+$name,
		type : 'iframe',
		padding : 5
	});
});
</script>
<style type="text/css">
.selectImg{
	position:absolute;
	top:5px;
	left:140px;
}
</style>